package com.jk.admin.controller;


import com.jk.admin.entity.Cart;
import com.jk.admin.entity.User;
import com.jk.admin.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/*
   （购物车Controller）
    宋林轩
 */


@RestController
@RequestMapping("cart")
public class CartController {

    @Autowired
    private CartService cartService;
    
    /**
     * @Author 宋林轩
     * @Description //TODO 查询redis购物车
     * @Date 10:47 2021/3/30
     * @Param [page, rows]
     * @return java.util.List<com.jk.admin.entity.Cart>
     */
    @RequestMapping("queryCartList")
    public List<Cart> queryCartList(HttpServletRequest request){
        List<Cart> list = cartService.queryCartList(request);
        return list;
    }
    
    /**
     * @Author 宋林轩
     * @Description //TODO 添加购物车
     * @Date 9:42 2021/3/31
     * @Param [request, productId, num]
     * @return void
     */
    @RequestMapping("addCart")
    public void addCart(HttpServletRequest request,String productId,Integer num){
        cartService.addCart(request,productId,num);
    }
    
    /**
     * @Author 宋林轩
     * @Description //TODO  测试添加
     * @Date 9:42 2021/3/31
     * @Param [cart]
     * @return void
     */
    @RequestMapping("add")
    public void add(Cart cart){
        cartService.add(cart);
    }

    /**
     * @Author 宋林轩
     * @Description //TODO 删除
     * @Date 16:44 2021/3/31
     * @Param [id]
     * @return void
     */
    @RequestMapping("del")
    public void del(String id,String productId){
        cartService.del(id,productId);
    }

}
